<?php

require './vendor/autoload.php';

class phpPdfParserChajian extends Chajian
{   
    /**
     * PHP通过PDFParser解析PDF文件
     * @param array $data 必填 一维数组
     * @param string $path 必填 模板文件路径
     * @param array $dataRow 选填 excel数据 二维数组
     * @param string $filename 选填 文件名称
     * TCPDF-示例：认证签名（实验性）
     * 参考：PHP通过PDFParser解析PDF文件-https://blog.csdn.net/weixin_34198453/article/details/93467480
     * @return bool
     */
    public function  analysispdf($filepath){
        //$pdfFile = $filepath;
        $pdfFile = 'http://wodeoa.hcaskj.com/upload/2020-12/16_17341550.pdf';
        //读取pdf，验证跟踪号是否一致
        // Parse pdf file and build necessary objects.
        $parser = new \Smalot\PdfParser\Parser();

        //$pdfPath = $_SERVER['DOCUMENT_ROOT'].$pdfFile;
        $pdfPath = $pdfFile;
        $pdf  = $parser->parseFile($pdfPath);
        //var_dump($pdf);die;
        $text = $pdf->getText();
        Header("Content-Type:text/html;charset=utf-8");

        // Retrieve all details from the pdf file.
        $details  = $pdf->getDetails();
        var_dump($text);var_dump($details);die();

    }
}
